<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="includes.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/jot.css" type="text/css" rel="stylesheet">
</head>
<body>
    <form id="teamForm" action="" title="${position.team.name}" class="dlg">
        <div class="dlg">
        <input type="hidden" value="${position.team.name}" id="dlg_title"/>
        
        <c:if test="${! empty message}">
            <h4><spring:message code="${message}"/>${infoString}</h4>
            <hr/>
        </c:if>
        
        <c:if test="${!empty position.obtainedTask}">
            <table>
                <tr>
                    <td style="width: 100%">
                        <h4 style="margin: 5px 0px"><spring:message code="messages.team.task"/></h4>
                    </td>
                </tr>
                <tr>
                    <td class="team-info" style="padding-bottom: 0px;">
                        <h5>${position.obtainedTask.task.name}</h5>
                    </td>
                </tr>
                <tr>
                    <td class="team-info" colspan="2">
                        <spring:message code="messages.ts.obtained"/>&nbsp;<joda:format value="${position.obtainedTask.start}" pattern="HH:mm"/>
                    </td>
                </tr>
                <c:if test="${! empty position.obtainedTask.firstHint}">
                    <tr>
                       <td class="team-info">
                           <spring:message code="messages.ts.first_hint"/>&nbsp;<joda:format value="${position.obtainedTask.firstHint}" pattern="HH:mm"/>
                       </td>
                    </tr>
                </c:if>
                <c:if test="${! empty position.obtainedTask.secondHint}">
                <tr>
                    <td class="team-info">
                        <spring:message code="messages.ts.second_hint"/>&nbsp;<joda:format value="${position.obtainedTask.secondHint}" pattern="HH:mm"/>
                    </td>
                </tr>
                </c:if>
                <tr>
                    <td class="team-info">
                        <spring:message code="messages.task.guessed_codes"/>:&nbsp;${position.obtainedTask.guessedCodes}
                    </td>
                </tr>
                <tr>
                    <td class="team-info">
                        <spring:message code="messages.task.left_codes"/>:&nbsp;${position.obtainedTask.answers}
                    </td>
                </tr>
                <tr>
                    <td class="team-info">
                        <table>
                            <tr>
                                <td>
                                    <h4 style="margin-bottom: -5px"><spring:message code="messages.task.guess"/></h4>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="text" id="guess" style="width: 50px;"/>
                                </td>
                                <td>
                                    <button class="btn" style="margin-left: 5px;" onclick="return extTryGuess(${position.team.id}, ${position.obtainedTask.task.id})">
                                        <spring:message code="messages.task.try_guess"/>&nbsp;(${position.obtainedTask.attemptsLeft})
                                    </button>
                                </td>
                                <td>
                                    <button class="btn" onclick="return extReject(${position.team.id}, ${position.obtainedTask.task.id})">
                                        <spring:message code="messages.task.reject"/>
                                    </button>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <hr style="margin-bottom: 0px; margin-top: 5px"/>
        </c:if>
        
        <table style="width: 100%">
            <tr>
                <td>
                    <h4><spring:message code="messages.team.stat"/></h4>
                </td>
                <td style="float: right; padding-bottom: 5px">
                    <div style="float: right">
                        <button type="button" class="btn" onclick="return changeTeamState(${position.team.id})">
                                <c:if test="${!position.team.blocked}">
                                    <spring:message code="messages.team.block"/>
                                </c:if>
                                <c:if test="${position.team.blocked}">
                                    <spring:message code="messages.team.unblock"/>
                                </c:if>
                        </button>
                    </div>
                </td>
            </tr>
        </table>
        <table class="team-info" style="margin-top: -10px">
            <tr>
                <td>
                    <spring:message code="messages.gs.quessed"/>:&nbsp;${position.guessed}
                </td>
            </tr>
            <tr>
                <td>
                    <spring:message code="messages.gs.timeout"/>:&nbsp;${position.timeout}
                </td>
            </tr>
            <tr>
                <td>
                    <spring:message code="messages.gs.rejected"/>:&nbsp;${position.rejected}
                </td>
            </tr>           
        </table>
        </div>
    </form>                      
</body>
</html>